package com.trkj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trkj.dao.FeiYongDao;
import com.trkj.entity.FeiYongEntity;
import com.trkj.entity.HouseEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class FeiYongServiceImpl implements FeiYongService{

    @Autowired
    private FeiYongDao feiYongDao;

    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<FeiYongEntity> selectFeiYongAll(FeiYongEntity feiYongEntity, int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<FeiYongEntity> List= this.feiYongDao.selectFeiYongAll(feiYongEntity);
        PageInfo<FeiYongEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }

    @Override
    public boolean addbillingltems(FeiYongEntity feiYongEntity){
        int count=feiYongDao.addbillingltems(feiYongEntity);
        return count>0;
    }

    @Override
    public List<FeiYongEntity> selectname() {
        List<FeiYongEntity> list = feiYongDao.selectname();
        return list;
    }
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<FeiYongEntity> selectAll(FeiYongEntity feiYongEntity , int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<FeiYongEntity> List= this.feiYongDao.selectFeiYongAll(feiYongEntity);
        PageInfo<FeiYongEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }


    @Override
    public boolean addFeiYong(FeiYongEntity feiYongEntity){
        int count=feiYongDao.addFeiYong(feiYongEntity);
        return count>0;
    }

    @Override
    public boolean addfwfyconnect(FeiYongEntity feiYongEntity){
        int count=feiYongDao.addfwfyconnect(feiYongEntity);
        return count>0;
    }


    @Override
    public Integer selectmax() {
        int max=feiYongDao.selectmax();
        return max;
    }
}
